/*
    The MIT License

    Copyright (c) 2010 IFMO/GameDev Studio

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/


#pragma once

/*-----------------------------------------------------------------------------
	Exceptions :
-----------------------------------------------------------------------------*/

#define RAISE_RUNTIME_ERROR(s)			throw runtime_error((const char*)s)
#define BAD_REFERENCE(s)				throw bad_reference((const char*)s)
#define RAISE_VIDEO_EXCEPTION(s)		throw video_exception((const char*)s)
#define RAISE_SOUND_EXCEPTION(s)		throw sound_exception((const char*)s)
#define RAISE_GAME_EXCEPTION(s)			throw game_exception((const char*)s)
#define RAISE_SCRIPT_EXCEPTION(s)		throw script_exception((const char*)s)
#define RAISE_FILESYSTEM_EXCEPTION(s)	throw filesystem_exception((const char*)s)


//
//	bad_reference
//	- it happens while trying to acces to NULL-pointer (HardRef and weak_ref)
//
class bad_reference : public std::runtime_error	{
	public:
		explicit bad_reference	(const std::string& _Message) : runtime_error(_Message) { }
		virtual ~bad_reference	() {	}
	};



//
//	video_exception
//	- it happens when some rendering-specific error occures
//
class video_exception : public std::runtime_error	{
	public:
		explicit video_exception	(const std::string& _Message) : runtime_error(_Message) { }
		virtual ~video_exception	() {	}
	};


//
//	video_exception
//	- it happens when some error occurs inside sound system
//
class sound_exception : public std::runtime_error	{
	public:
		explicit sound_exception	(const std::string& _Message) : runtime_error(_Message) { }
		virtual ~sound_exception	() {	}
	};


//
//	video_exception
//	- it happens when some error occurs inside sound system, such as
//	unknown game object class, violatin game logic, server erros etc
//
class game_exception : public std::runtime_error	{
	public:
		explicit game_exception	(const std::string& _Message) : runtime_error(_Message) { }
		virtual ~game_exception	() {	}
	};


//
//	script_exception
//	- lua script or shader compilation error 
//
class script_exception : public std::runtime_error	{
	public:
		explicit script_exception	(const std::string& _Message) : runtime_error(_Message) { }
		virtual ~script_exception	() {	}
	};


//
//	script_exception
//	- file IO errors, such as: can't open or create file, can't create directory etc
//
class filesystem_exception : public std::runtime_error	{
	public:
		explicit filesystem_exception	(const std::string& _Message) : runtime_error(_Message) { }
		virtual ~filesystem_exception	() {	}
	};

